package com.mairuide.base_dict.holiday.controller;

import com.mairuide._frame.base.BaseController;
import com.mairuide.base_dict.holiday.dto.HolidayDto;
import com.mairuide.base_dict.holiday.pojo.Holiday;
import com.mairuide.base_dict.holiday.service.HolidayService;
import com.mairuide.entity.PageResult;
import com.mairuide.entity.Result;
import com.mairuide.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description
 * @auther 刘中华
 * @create 2019-06-04 15:02
 */
@RequestMapping("/holiday")
@Controller
public class HolidayController extends BaseController {
    @Autowired
    HolidayService holidayService;

    @RequestMapping("index")
    public String index(){
        return "/base_dict/holiday/holiday";
    }
    @RequestMapping("openHolidayDialog")
    public String openHolidayDialog(){
        return "/base_dict/holiday/openHolidayDialog";
    }

    //保存节假日
    @RequestMapping("save")
    @ResponseBody
    public Result save(Holiday sd){
        holidayService.save(sd);
        return new Result(true, StatusCode.OK,"保存成功" );
    }
    //查询节假日
    @RequestMapping("findOneById")
    @ResponseBody
    public Result findOneById(Integer id){
        Holiday holiday = holidayService.findOnebyId(id);
        return new Result(true, StatusCode.OK,"保存成功" ,holiday);
    }
    //删除节假日
    @RequestMapping("del")
    @ResponseBody
    public Result del(Integer id){
        holidayService.del(id);
        return new Result(true, StatusCode.OK,"删除成功" );
    }
    //分页查询节假日
    @RequestMapping("page")
    @ResponseBody
    public PageResult query(HolidayDto dto){
        PageResult page = holidayService.findByPage(dto);
        return page;
    }
}
